<?php
namespace Orm\Article;
class ArticleList extends \Base\BaseOrmObjectLists{

    // for function keyBy()
    protected $key_by;

    function __construct()
    {
        parent::__construct();
        $this->dbo = new \Orm\Article\ArticleModel();
        $this->filter = '`is_del` = 0';
        $this->order ='';
    }

    function newObj()
    {
        return new \Orm\Article\ArticleClass();
    }

    /**
     * keyBy
     * @param  string $field
     * @return obj
     * @author imjcw
     * @date   2016-11-08
     */
    public function keyBy($field)
    {
        $this->key_by = $field;
        return $this;
    }

    /**
     * 完善用户信息
     * @param $uids
     * @return array
     */
    public function completeUserInfo($uids)
    {
        if(count($uids) == 0) return array();
        $user_openid_list = new \Orm\User\UserList();
        $user_openid_list['limit'] = \Util\Config::get('max_limit');
        $user_openid_list['where'] = "id IN (".implode($uids,',').")";
        $user_openid_list->load();
        return $user_openid_list['lists'];
    }

    /**
     * 完善内容信息
     * @param $ids
     * @return array
     */
    public function completeContent($ids)
    {
        if(count($ids) == 0) return array();
        $content_openid_list = new \Orm\ArticleContent\ArticleContentList();
        $content_openid_list['limit'] = \Util\Config::get('max_limit');
        $content_openid_list['where'] = "article_id IN (".implode($ids,',').")";
        $content_openid_list->load();
        return $content_openid_list['lists'];
    }

}